#include "physics/pbullet.h"

#include <QDomElement>

PBullet::PBullet(PWorld *world, QString name) : PObject(world, QString("bullet_%1").arg(name))
{
    setM(0.0001);
    setDamage(34);
    setLife(11);
    setR(1);
}

void PBullet::serialize(QDomDocument *doc, QDomElement *e) const {
    e->setAttribute("type", "Bullet");
    PObject::serialize(doc, e);
}

PBullet *PBullet::deserialize(QDomNode *e, PWorld *parent) {
    PObject *obj = PObject::deserialize(e, 0);
    PBullet *bullet = new PBullet(parent, obj->getName());
    bullet->setBrightness(obj->getBrightness());
    bullet->setDamage(obj->getDamage());
    bullet->setLife(obj->getLife());
    bullet->setM(obj->getM());
    bullet->setPos(obj->getPos());
    bullet->setR(obj->getR());
    bullet->setV(obj->getV());

    delete obj;
    return bullet;
}
